package com.markerhub.mapper;

import com.markerhub.entity.ManagerActivity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface ManagerActivityMapper extends BaseMapper<ManagerActivity> {

    @Select("SELECT DATE_FORMAT(created_time, '%Y-%m') as month, " +
            "COUNT(*) as count " +
            "FROM m_manager_activity " +
            "WHERE created_time >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH) " +
            "GROUP BY DATE_FORMAT(created_time, '%Y-%m') " +
            "ORDER BY month")
    List<Map<String, Object>> selectActivityTrend();
}
